<template>
  <template v-for="(item, index) in props.menudata">
    <el-menu-item
      @click="handlclick(item,`${props.index}-${item.meta.id}`)"
      v-if="!item.children || item.children == 0"
      :index="`${props.index}-${item.meta.id}`"
      :key="`${props.index}-${item.meta.id}`"
    >
      <el-icon size="20">
        <component :is="item.meta.icon"></component>
      </el-icon>
      <span>{{ item.meta.name }}</span>
    </el-menu-item>
    <el-sub-menu v-else :index="`${props.index}-${item.meta.id}`"> 
      <template #title>
        <el-icon size="20">
          <component :is="item.meta.icon"></component> </el-icon
      >
      <span>{{ item.meta.name }}</span>
    </template>
      <treemenu :index="`${props.index}-${item.meta.id}`" 
      :menudata="item.children"></treemenu>
    </el-sub-menu>
  </template>
</template>

<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
const props = defineProps(["menudata","index"]);
const handlclick = (item, active) => {
    router.push(item.meta.path)
}

</script>

<style lang="less" scoped></style>
